package com.example.demo.controller;

import com.example.demo.model.Student;

import com.example.demo.model.Teacher;

import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("student")
public class StudentController {
    @RequestMapping("list")
    public String list(ModelMap modelMap) {
        List<Student> studentList = new ArrayList<>();
        Student s1 = new Student();
        s1.setId(1);
        s1.setName("Tom");
        studentList.add(s1);
        modelMap.put("studentList", studentList);
        Teacher teacher = new Teacher();
        teacher.setId(10);
        teacher.setName("Jerry");
        Student s2=new Student();
        s2.setId(2);
        s2.setName("Jack");
        studentList.add(s2);
        modelMap.put("teacher", teacher);
        return "student/list";
    }
}